package action;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.serializer.SerializerFeature;

import service.ReportFormService;

/**
 * @author bohan
 * @create 2017年5月15日
 */
public class ReportFormAction {
	private ReportFormService service;
	private JSONArray root;
	private String begindate;
	private String enddate;
	private String range;
	
	public String getMonthForm(){
		List list = new ArrayList();
		Date date = new Date();
		int year = date.getYear()+1900;
		System.out.println(year);
		for(int i = 0; i < Integer.parseInt(range) ;i++){
			list.add(service.getMonthForm(String.valueOf(year)));
			year--;
		}
		root = JSONArray.parseArray(JSON.toJSONString(list,SerializerFeature.DisableCircularReferenceDetect));
		return "success";
	}
	
	public String getForm(){
		List list = new ArrayList();	
		list = service.getForm(begindate, enddate);
		root = JSONArray.parseArray(JSON.toJSONString(list,SerializerFeature.DisableCircularReferenceDetect));
		return "success";
	}

	public ReportFormService getService() {
		return service;
	}

	public void setService(ReportFormService service) {
		this.service = service;
	}

	public JSONArray getRoot() {
		return root;
	}

	public void setRoot(JSONArray root) {
		this.root = root;
	}

	public String getBegindate() {
		return begindate;
	}

	public void setBegindate(String begindate) {
		this.begindate = begindate;
	}

	public String getEnddate() {
		return enddate;
	}

	public void setEnddate(String enddate) {
		this.enddate = enddate;
	}

	public String getRange() {
		return range;
	}

	public void setRange(String range) {
		this.range = range;
	}
	
	
}
